package com.gisocn.onemap.widget;

import android.content.Context;
import android.util.Log;
import android.widget.TextView;
import com.gisocn.onemap.model.Statistic;
import com.gisocn.onemap.sgzx.R;
import com.github.mikephil.charting.components.MarkerView;
import com.github.mikephil.charting.data.BarEntry;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.PieEntry;
import com.github.mikephil.charting.highlight.Highlight;
import com.github.mikephil.charting.utils.MPPointF;
import java.text.DecimalFormat;
import java.util.ArrayList;

/* loaded from: classes2.dex */
public class CustomMarkerView extends MarkerView {
    DecimalFormat decimalFormat;
    ArrayList<Statistic> list;
    TextView tvMarkerViewName;
    TextView tvMarkerViewValue;
    private int type;

    public CustomMarkerView(Context context, int i, int i2, ArrayList<Statistic> arrayList) {
        super(context, i);
        this.decimalFormat = new DecimalFormat("0.00");
        this.tvMarkerViewName = (TextView) findViewById(R.id.tv_mark_view_name);
        this.tvMarkerViewValue = (TextView) findViewById(R.id.tv_mark_view_value);
        this.type = i2;
        this.list = arrayList;
    }

    @Override // com.github.mikephil.charting.components.MarkerView, com.github.mikephil.charting.components.IMarker
    public void refreshContent(Entry entry, Highlight highlight) {
        if (this.type == 0) {
            PieEntry pieEntry = (PieEntry) entry;
            this.tvMarkerViewName.setText(pieEntry.getLabel());
            TextView textView = this.tvMarkerViewValue;
            textView.setText(this.decimalFormat.format(pieEntry.getValue()) + "%");
            Log.e("refreshContent", "" + pieEntry.getLabel());
            Log.e("refreshContent", "" + this.decimalFormat.format((double) pieEntry.getValue()));
        } else {
            BarEntry barEntry = (BarEntry) entry;
            TextView textView2 = this.tvMarkerViewName;
            textView2.setText(this.list.get((int) barEntry.getX()).getName() + ", " + this.decimalFormat.format(barEntry.getY()) + "");
        }
        super.refreshContent(entry, highlight);
    }

    @Override // com.github.mikephil.charting.components.MarkerView, com.github.mikephil.charting.components.IMarker
    public MPPointF getOffset() {
        return new MPPointF(-(getWidth() / 2), -getHeight());
    }
}
